/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.api.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.emoji.EmojiUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.app.dto.MyOrderDto;
import com.yami.shop.bean.app.dto.UserDto;
import com.yami.shop.bean.app.param.UserInfoParam;
import com.yami.shop.bean.model.User;
import com.yami.shop.common.util.CacheManagerUtil;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.security.enums.App;
import com.yami.shop.security.util.SecurityUtils;
import com.yami.shop.service.UserService;
import com.yami.shop.sys.model.SysScoreLog;
import com.yami.shop.sys.service.SysScoreLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import ma.glasnost.orika.MapperFacade;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/p/score")
@Api(tags="积分接口")
@AllArgsConstructor
public class ScoreController {

	private final SysScoreLogService sysScoreLogService;
    
	private final MapperFacade mapperFacade;

	private final CacheManagerUtil cacheManagerUtil;
    /**
     * 查看积分日志接口
     */
    @GetMapping("/scoreLog")
    @ApiOperation(value="查看用户积分信息", notes="根据用户ID（userId）获取用户积分记录信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "积分类型 1:收入 2:支出", required = false, dataType = "Integer")
    })
    public ResponseEntity<IPage<SysScoreLog>> scoreLog(@RequestParam(value = "status") Integer status,PageParam<SysScoreLog> page){
        String userId = SecurityUtils.getUser().getUserId();
        IPage<SysScoreLog> sysScoreLogs = sysScoreLogService.page(page,
                new LambdaQueryWrapper<SysScoreLog>()
                        .like(StrUtil.isNotBlank(userId), SysScoreLog::getUserid,userId)
                        .eq(status>0,SysScoreLog::getStatus,status)
                );
        return ResponseEntity.ok(sysScoreLogs);
    }



}
